/**
 * Created by Lixia on 2017/6/4.
 */
$(function () {
    var moveBg=$('.move-bg')
    $('.nav').find('a').each(function (index,element) {
        $(element).mouseover(function () {
            moveBg.stop();
            var moveMeter=120*index;
            var flag=1;
            var ext=30;
            if(index*120<moveBg.position().left) {
                flag = -1;
                moveMeter=moveMeter + ext * flag;
            }else {
                moveMeter = 120 * index + ext;
            }
            moveBg.animate({left:moveMeter+'px'},200,function () {
                moveBg.stop();
                moveBg.animate({left:moveMeter+ext*flag*-1+'px'});
            });
        })
    });
});